package com.itaem.community.modules.patrol.record.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.itaem.community.CommunityApplication;
import com.itaem.community.modules.patrol.location.entity.PatrolLocationEntity;
import com.itaem.community.modules.patrol.location.service.PatrolLocationService;
import com.itaem.community.modules.patrol.record.Util.LatLonUtil;
import com.itaem.community.modules.patrol.record.entity.PatrolRecordEntity;
import com.itaem.community.modules.patrol.record.service.PatrolRecordService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

@RunWith(SpringRunner.class)
@SpringBootTest
public class PatrolRecordController {
    @Autowired
    private PatrolRecordService patrolRecordService;
    @Autowired
    private PatrolLocationService patrolLocationService;

    @Test
    public void test01(){
        int id = 2;
        int rid = 2;

        PatrolLocationEntity patrolLocationEntity = patrolLocationService.getById(id);
        PatrolRecordEntity patrolRecordEntity = patrolRecordService.getById(rid);

        double Latitude = patrolLocationEntity.getLatitude();
        double Longitude = patrolLocationEntity.getLongitude();

        System.out.println(Latitude);
        System.out.println(Longitude);
        double[] around = LatLonUtil.getAround(Latitude,Longitude,100);
        if (patrolRecordEntity.getLatitude()>around[0]&&patrolRecordEntity.getLatitude()<around[2]&&patrolRecordEntity.getLongitude()>around[1]&&patrolRecordEntity.getLongitude()<around[3]){
            System.out.println("打卡成功");
        }else{
            System.out.println("打卡失败");
        }

    }
}
